import { load } from 'cheerio'

/**
 * 向 HTML 中注入
 */
export const injectToHTML = (
  html: string,
  content: string,
  dom: string = 'body',
  position: 'append' | 'prepend' = 'append',
) => {
  const $ = load(html)

  switch (position) {
    case 'append':
      $(dom).append(content)
      break
    case 'prepend':
      $(dom).prepend(content)
      break
  }

  return $.html()
}
